package com.fh.modules.oms.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fh.common.api.vo.Result;
import com.fh.common.aspect.annotation.AutoLog;
import com.fh.common.constant.CommonConstant;
import com.fh.common.query.QueryWrapperUtil;
import com.fh.modules.oms.entity.OmsShoppingCar;
import com.fh.modules.oms.service.IOmsShoppingCarService;
import com.fh.modules.oms.vo.ShoppingCarVo;
import com.fhMall.request.QueryShoppingCarRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

 /**
 * @Title: Controller
 * @Description: 购物车
 * @author： code generator
 * @date：   2019-09-28
 * @version： V1.0
 */
@RestController
@Slf4j
@Api("购物车")
public class OmsShoppingCarController {
	@Autowired
	private IOmsShoppingCarService omsShoppingCarService;
	
	/**
	  * 分页列表查询
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	@GetMapping(value = "/oms/omsShoppingCar/list")
	@ApiOperation("分页列表查询")
	@AutoLog(value="购物车分页查询",logType=CommonConstant.LOG_TYPE_QUERY)
	public Result queryPageList( @RequestParam("memberId")Integer memberId,
								@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
		return Result.okPage(omsShoppingCarService.queryMemberShoppingCar(memberId,pageNo, pageSize));
	}
	
	/**
	  *   添加
	 * @return
	 */
	@PostMapping(value = "/oms/omsShoppingCar/add")
	@ApiOperation("添加")
	@AutoLog("添加购物车")
	public Result add(@RequestBody ShoppingCarVo shoppingCarVo ) {
		omsShoppingCarService.add(shoppingCarVo);
		return Result.ok("添加成功");
	}

	
	/**
	  *  批量删除
	 * @param ids
	 * @return
	 */
	@DeleteMapping(value = "/oms/omsShoppingCar/deleteBatch")
	@ApiOperation("批量删除")
	@AutoLog("批量删除购物车")
	public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		omsShoppingCarService.deleteBatchEntityByDelFlag(ids);
		return Result.ok("批量删除成功");
	}

}
